﻿package
{
	import flash.net.*;
	import flash.events.*;
	import flash.display.*;
	import flash.media.*;
	
	public class LiveStream extends Sprite
	{
		private var video:Video;
		private var nc:NetConnection;
		private var ns:NetStream;
		
		public function LiveStream():void
		{
			nc = new NetConnection();
//			nc.connect("rtmp://localhost/LiveStreams");
			nc.client = this;
			nc.connect("rtmp://192.168.1.209/live");
			nc.addEventListener(NetStatusEvent.NET_STATUS,onNetStatusHandler);
		}
		
		private function onNetStatusHandler(evt:NetStatusEvent):void
		{
			trace(evt.info.code);
			if(evt.info.code=="NetConnection.Connect.Success")
			{
				ns=new NetStream(nc);
				ns.addEventListener(NetStatusEvent.NET_STATUS,onNetStatusHandler);
				ns.client=new CustomClient();
				video=new Video();
				video.attachNetStream(ns);
				ns.play("stream");
				addChild(video);
			}
		}
		
		public function onBWDone():void
		{
		}
	}
}